import Taro, { Component } from '@tarojs/taro'
import { AtButton } from 'taro-ui'
import classnames from 'classnames'
import PropsType from 'prop-types'
import { View, Text, Image } from '@tarojs/components'
import '../styles/advance.scss'

const carIcon = require('../assete/icon_car.png')

export default class DAdvance extends Component {

  onHandleDetail() {
    this.props.onHandleDetail && this.props.onHandleDetail()
  }

  onHandleFirst(e) {
    e.stopPropagation()
    this.props.onHandleFirst && this.props.onHandleFirst()
  }
  onHandleLast(e) {
    e.stopPropagation()
    this.props.onHandleLast && this.props.onHandleLast()
  }
  render() {
    const {
      className,
      order,
      status,
      list,
      flag,
      tipmoney,
      contract,
      total,
      money,
      firstText,
      lastText,
      vehicleOwnerName,
      createTime
    } = this.props

    return (
      <View className={classnames('b_advance', className)} onClick={this.onHandleDetail.bind(this)}>
        <View className='b_advance__munber'>
          <View className='b_advance__munber_left'>
            {/* <Text className='b_advance__munber_text'>垫</Text>
                        <Text className='b_advance__munber_item'>{order}</Text> */}
          </View>
          <View className='b_advance__munber_status'>{status}</View>
        </View>
        <View className='b_advance__title'>
          {/* <Image src={carIcon} className='b_advance__title_icon'></Image> */}
          <View className="b_advance__title_label">车型：</View>
          <View className='b_advance__title_content'>
            {
              list && list.map((item, i) => {
                return <View className='b_advance__itemtitle' key={i}>{item}</View>
              })
            }
          </View>
        </View>
        <View className='b_advance__title'>
          <View className="b_advance__title_label">车主：</View>
          <View className='b_advance__title_content'>
            <View className="b_advance__itemtitle">{vehicleOwnerName}</View>

          </View>
        </View>
        <View className='b_advance__title'>
          <View className="b_advance__title_label gray_color">申请时间：</View>
          <View className='b_advance__title_content'>
            <View className="b_advance__itemtitle gray_color">{createTime}</View>
          </View>
        </View>
        {/* <View className='b_advance__flag'>
                    <View className='b_advance__flag_list'>
                        {
                            flag && flag.map((item, j) => {
                                return <Text key={j} className='b_advance__itemflag'>{item}</Text>
                            })
                        }
                    </View>
                    <View className='b_advance__flag_tip'>市场指导价：{window.toFixed(tipmoney)}万元</View>
                </View> */}

        {/* <View className='b_advance__wrapper_m'>
                  <View className='b_advance__addre'>合同金额：{window.toFixed(contract)}</View>
                  <View className='b_advance__footer_left'>
                        <Text className='b_advance__footer_left__total'>申请金额:</Text>
                        <Text className='b_advance__footer_left__money'>{window.toFixed(money)}万元</Text>
                  </View>
                </View> */}

        <View className='b_advance__footer'>
          {
            firstText && <AtButton onClick={this.onHandleFirst.bind(this)}>{firstText}</AtButton>
          }
          {
            lastText && <AtButton onClick={this.onHandleLast.bind(this)}>{lastText}</AtButton>
          }
        </View>
      </View>
    )
  }
}

DAdvance.defaultProps = {
  className: '',
  order: 'CL20191114001',
  status: '待审核',
  list: ['保时捷718', '2018款', 'Cayman', '2.0T'],
  flag: ['中规', '国六', '蓝/黑'],
  tipmoney: '60.00',
  contract: '60.00万元',
  total: '1',
  money: '60.99',
  firstText: '',
  lastText: '',
  onHandleDetail: () => { },
  onHandleFirst: () => { },
  onHandleLast: () => { }
}

DAdvance.PropsType = {
  className: PropsType.oneOfType[PropsType.string, PropsType.object],
  order: PropsType.string,
  status: PropsType.string,
  list: PropsType.array,
  flag: PropsType.array,
  tipmoney: PropsType.string,
  contract: PropsType.string,
  total: PropsType.oneOfType[PropsType.number, PropsType.string],
  money: PropsType.string,
  firstText: PropsType.string,
  onHandleDetail: PropsType.func,
  onHandleFirst: PropsType.func,
  onHandleLast: PropsType.func,
  lastText: PropsType.string
}
